<div class="cp-box1">
   <div style="padding: 5px 0px; text-align: right;" id="params_dev">
	   	<input type="hidden" id="betDate" value="2017-08-26">
	   	<select id="betGameId" class="ag-select" style="overflow: auto">
        </select>
		<span>
			<a href="#" id="back2log">返回</a>
		</span>
   </div>
   <table class="u-table2 log2-detail"> 
    <thead> 
     <tr> 
      <th class="u-tb3-th2" style="width: 130px; height: 26px; font-size: 13px; color: #762d08;">定单号</th> 
      <th class="u-tb3-th2" style="width: 100px; height: 26px; font-size: 13px; color: #762d08;">时间</th> 
      <th class="u-tb3-th2" style="width: 180px; height: 26px; font-size: 13px; color: #762d08;">类型</th> 
      <th class="u-tb3-th2" style="width: 220px; height: 26px; font-size: 13px; color: #762d08;">玩法</th> 
      <th class="u-tb3-th2" style=" height: 26px; font-size: 13px; color: #762d08;">下注金额</th> 
      <th class="u-tb3-th2" style=" height: 26px; font-size: 13px; color: #762d08;">退水</th> 
      <th class="u-tb3-th2" style="width: 100px; height: 26px; font-size: 13px; color: #762d08;"><span id="column_desc">结果</span></th> 
     </tr>
    </thead>
    <tbody id="bet_list_body">				         
    </tbody> 
   </table>
   <div class="zxf_pagediv megas512"></div>
   <div style="height:40px"></div>
</div>

<style type="text/css">
    #preWeekTable a, #back2log {
        color: blue;
    }
</style>

<script src="../public/all/js/page_list.js"></script>
<script>
    $("#back2log").click(function() {
        switch_page("center/log", $(".content-wrap"));
    });
    Util.fillGames($("#betGameId"));
    $("#betGameId").val(context.center.game);

    // 查看的日期
    var _date = context.center.date || new Date().Format("yyyy-MM-dd");

    var _f = Util.queryTemplate($(".log2-detail tbody"), ".zxf_pagediv", null, function(page, size, cb) {
        var data = {
            pageNum: page,
            pageSize: size,
            start: _date,
            end: _date,
            state: 1,
        };
        startLoading();
        CMD.query_bet_by_user($("#betGameId").val(), data, function(r) {
            stopLoading();
            cb(r);
        });
    }, function(table, list, sum) {
        if (Util.isEmpty(list)) {
            table.append("<tr><td colspan='7'>暂无数据</tr>");
            return;
        }

        for (var i in list) {
            var o = list[i];
            var tr = $("<tr></tr>");
            var target = Util.convertTarget(o.type, o.target);
            tr.append('<td class="f1" style="word-wrap: break-word;word-break:break-all;">' + o.id + '</td>');
            tr.append("<td class='f1'>" + new Date(o.time).Format("yyyy-MM-dd HH:mm:ss") + "</td>");
            tr.append("<td class='f1'>" + get_game_display_name(o.type) + "<br/>第&nbsp;<span style='color:#299a26'>" + o.issue + "</span>&nbsp;期</td>");
            tr.append("<td class='f1 multiple'><span style='color:#2836f4'> " + 
            target + " <span style='color:#000'>@<span style='color:red'>" + o.rate + "</span></td>");
            tr.append("<td class='f1'>" + (o.amount / 100) + "</td>");
            tr.append("<td class='f1'>" + (o.back ? o.back*100 : 0) + "%</td>");
                            
            tr.append("<td class='red f1'>" + (o.profit/100).toFixed(3) + "</td>");
            table.append(tr);
        }

        // 合计
        var tr = $("<tr></tr>");
        tr.append('<td class="f1" colspan="3"></td>');
        tr.append('<td class="f1">总计</td>');
        tr.append('<td class="f1">' + (sum.amount/100) + '</td>');
        tr.append('<td class="f1">' + (sum.back/100) + '</td>');

        if (sum.profit >= 0)
            tr.append('<td class="f1" style="color:red">' + (sum.profit/100) + '</td>');
        else
            tr.append('<td class="f1">' + (sum.profit/100) + '</td>');
        table.append(tr);
    }); 
    $("#betGameId").change(function() {
        _f();
    })
</script>